/*
题目链接：https://leetcode.cn/problems/minimum-limit-of-balls-in-a-bag/description/
1760. 袋子里最少数目的球-中等
完成日期：2024/9/28
二分搜索
*/
class Solution {
public:
    int minimumSize(vector<int>& nums, int maxOperations) {
        int l=1,r=*max_element(nums.begin(),nums.end()),ans=0;
        while(l<=r){
            int mid=(l+r)/2;
            long long k=0;
            for(int m: nums){
                k+=(m-1)/mid;
            }
            if(k<=maxOperations){
                ans=mid;
                r=mid-1;
            }else{
                l=mid+1;
            }
        }
        return ans;
    }
};